package com.zheng.damo01.HomeWeark05;

import org.w3c.dom.ls.LSOutput;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.Scanner;

public class 学生录入 {
    public static void main(String[] args) {
        Scanner s=new Scanner(System.in);
        ArrayList<Student> list=new ArrayList<>();
        while (true){
            System.out.print("选择（1.录入 0.退出）：");
            int number=Integer.parseInt(s.nextLine());
            if (number==1){
                System.out.print("姓名：");
                String name=s.nextLine();
                System.out.print("年龄：");
                Integer age=Integer.parseInt(s.nextLine());
                list.add(new Student(name,age));
            }
            if (number==0){
                break;
            }
        }
        Iterator<Student> iterator = list.iterator();
        while (iterator.hasNext()){
            System.out.println(iterator.next());
        }

    }
}
